﻿using Abp.Authorization;
using Abp.Localization;
using Abp.MultiTenancy;
using Mt.Site;
using Mt.Site.Core.Authorization;

namespace Mt.Site.Core.AccessStatistics.Permissions
{
    public class ASPermissionProvider: AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
            var pages = context.GetPermissionOrNull(AppPermissions.Pages) ?? context.CreatePermission(AppPermissions.Pages, L("Pages"));
            
            var manager = pages.CreateChildPermission(ASPermissions.Pages_Manage_AccessStatistics, L("AccessStatistics"), multiTenancySides: MultiTenancySides.Tenant);
            manager.CreateChildPermission(ASPermissions.Pages_Manage_AccessStatistics_Query, L("QueryAccessStatistics"), multiTenancySides: MultiTenancySides.Tenant);
            
        }

        private static ILocalizableString L(string name)
        {
            return new LocalizableString(name, MtSiteConsts.LocalizationSourceName_Permissions);
        }
    }
}
